package com.guigui.erp.controller;

import com.guigu.erp.dto.StorageGatherDetailsDto;
import com.guigu.erp.pojo.StorageGather;
import com.guigu.erp.pojo.StorageGatherDetails;
import com.guigu.erp.service.StorageGatherDetailsService;
import com.guigu.erp.utils.PageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author Lenovo
 */
@Controller
@RequestMapping("/storageGather/details")
public class StorageGatherDetailsController {
    @Autowired
    private StorageGatherDetailsService storageGatherDetailsService;

    /**
     * 入库明细查询
     */
    @RequestMapping("/StorageGatherDetailsPage")
    @ResponseBody
    public PageUtils<StorageGatherDetails> StorageGatherDetailsPage(Integer parentId, int pageNo, int pageSize) {
        System.out.println(parentId);
        PageUtils<StorageGatherDetails> page =storageGatherDetailsService.gatherDetailsPage(parentId,pageNo, pageSize);
        return page;
    }

    /**
     * 根据入库id查询入库明细单信息
     */
    @RequestMapping("/storageGatherDetailsGetId")
    @ResponseBody
    public StorageGatherDetails storageGatherDetailsGetId(int id) {
        StorageGatherDetails storageGatherDetails = this.storageGatherDetailsService.getById(id);
        return storageGatherDetails;
    }

    /**
     * 通过id查询 入库表和入库明细表
     */
    @RequestMapping("/listByParentId")
    @ResponseBody
    public StorageGatherDetailsDto listByParentId(String productId){
        StorageGatherDetailsDto pageUtils=storageGatherDetailsService.listByParentId(productId);
        return pageUtils;
    }

    /**
     * 入库明细回显复核
     */
    @RequestMapping("/listByIdDetails")
    @ResponseBody
    public List<StorageGatherDetails> byIdDetails(int id){
        List<StorageGatherDetails> fuheById=storageGatherDetailsService.detailsById(id);
        return fuheById;
    }

    @RequestMapping("/update")
    @ResponseBody
    public String update(@RequestBody StorageGatherDetailsDto storageGatherDetailsDto){
        System.out.println("数据"+storageGatherDetailsDto);
        storageGatherDetailsService.updateDto(storageGatherDetailsDto);
        return "correct";
    }
}
